from flask import Flask, request, render_template
from Mar30.pcUtils import *
from bs4 import BeautifulStoneSoup

app = Flask(__name__)


@app.route("/")
def index():
    return render_template("index.html")


@app.route("/login", methods=['POST','GET'])
def login():
    username = request.form['username']
    print(username)
    userpwd = request.form['userpwd']
    if username=='admin':
        if userpwd=="123":
            return render_template("pc.html")
        else:
            return "密码错误"
    else:
        return "对不起密码错误"
@app.route("/scrawl",methods=["POST","GET"])
def scrawl():
    name = request.form["name"]
    url = request.form["targeturl"]
    s = Scrawler()
    targetText = s.getTargetText(url,selector='p')
    return str(targetText)

if __name__ == "__main__":
    app.run()